package com.wyt.design.designmodel.observer;

import java.util.Observable;
import java.util.Observer;

/**
 * @author weiyatong
 * @version 1.0
 * @date 2021/6/27 下午6:59
 * @describe 观察者
 */
public class HomePriceObserver implements Observer {
    private String name;

    public HomePriceObserver(String name) {
        this.name = name;
    }

    @Override
    public void update(Observable o, Object arg) {
        //这里最好判断一下通知是否来自于房价，有可能来自其它地方
        if (o instanceof Home) {
            System.out.println("购物者" + name + "观察到房价已调整为：" + arg);
        }
    }
}
